chdir( ".." );
require( './includes/WebStart.php' );
-$installer = new WebInstaller( $wgRequest );
+wfInstallerMain();
-if ( !$installer->startSession() ) {
- $installer->finish();
- exit;
-}
+function wfInstallerMain() {
+ global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
-$session = isset( $_SESSION['installData'] ) ? $_SESSION['installData'] : array();
+ $installer = new WebInstaller( $wgRequest );
-if ( isset( $session['settings']['_UserLang'] ) ) {
- $langCode = $session['settings']['_UserLang'];
-} elseif ( !is_null( $wgRequest->getVal( 'UserLang' ) ) ) {
- $langCode = $wgRequest->getVal( 'UserLang' );
-} else {
- $langCode = 'en';
-}
-$wgLang = Language::factory( $langCode );
+ if ( !$installer->startSession() ) {
+ $installer->finish();
+ exit;
+ }
+
+ $fingerprint = $installer->getFingerprint();
+ if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
+ $session = $_SESSION['installData'][$fingerprint];
+ } else {
+ $session = array();
+ }
-$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
+ if ( isset( $session['settings']['_UserLang'] ) ) {
+ $langCode = $session['settings']['_UserLang'];
+ } elseif ( !is_null( $wgRequest->getVal( 'UserLang' ) ) ) {
+ $langCode = $wgRequest->getVal( 'UserLang' );
+ } else {
+ $langCode = 'en';
+ }
+ $wgLang = Language::factory( $langCode );
-$session = $installer->execute( $session );
+ $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
-$_SESSION['installData'] = $session;
+ $session = $installer->execute( $session );
+ $_SESSION['installData'][$fingerprint] = $session;
+
+}
return count( $parts ) == 1 ? $parts[0] : $parts[1];
}
+ /**
+ * Get a hash of data identifying this MW installation.
+ *
+ * This is used by config/index.php to prevent multiple installations of MW
+ * on the same cookie domain from interfering with each other.
+ */
+ public function getFingerprint() {
+ // Get the base URL of the installation
+ $url = $this->request->getFullRequestURL();
+ if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
+ $url = $m[1];
+ }
+ return md5( serialize( array(
+ 'local path' => dirname( dirname( __FILE__ ) ),
+ 'url' => $url,
+ 'version' => $GLOBALS['wgVersion']
+ ) ) );
+ }
+
/**
* Show an error message in a box. Parameters are like wfMsg().
*/
return $url;
}
-}
\ No newline at end of file
+}